<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="msg"></div>
  <input type="text" id="ipt" oninput="getVal(this)">
</body>
<script>
  // 7
  var msg = document.getElementById('msg')
  var ipt = document.getElementById('ipt')
  // 1.
  var user = { userName: '吴大勋' }
  // 3
  var obj = {}
  // 4
  Object.defineProperty(obj, 'name', {
    get () { // 4
      return user.userName
    },
    set (val) { // 5
      user.userName = val
      msg.innerHTML = user.userName
    }
  })

  // 5
  obj.name = '吴勋勋'
  // 8
  ipt.value = user.userName
  // 2   6
  console.log(user.userName)
  // 3   6
  console.log(obj.name)

  // 9
  function getVal (e) {
    console.log(e)
    msg.innerHTML = e.value
  }

</script>
</html>